﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using XiaoGang.Soft.XGWMS.COM;
using XiaoGang.Soft.XGWMS.MODEL;

namespace XiaoGang.Soft.XGWMS.DAL_SQL
{
    public class DAL_System
    {
        /// <summary>
        /// 清楚冗余货单信息
        /// </summary>
        /// <returns></returns>
        public string DeleteBillGarbage (out int ReCount)
        {
            return XGWMS.DBUtility.SqlHelper.ExecuteSql(DAL_System_SQL.DeleteBillGarbage,out ReCount);
        }

        /// <summary>
        /// 清除冗余商品信息[已删除并且没有销售记录]
        /// </summary>
        /// <param name="ReCount"></param>
        /// <returns></returns>
        public string DeleteGoodsGarbage(out int ReCount)
        {
            return XGWMS.DBUtility.SqlHelper.ExecuteSql (DAL_System_SQL.DeleteGoodsGarbage, out ReCount);
        }

        /// <summary>
        /// 清除冗余商品分类信息[已删除并且没有被使用]
        /// </summary>
        /// <param name="ReCount"></param>
        /// <returns></returns>
        public string DeleteGoodsGroupGarbage ( out int ReCount )
        {
            return XGWMS.DBUtility.SqlHelper.ExecuteSql (DAL_System_SQL.DeleteGoodsGroupGarbage, out ReCount);
        }

        /// <summary>
        /// 清除冗余会员信息[已删除并且没有消费记录]
        /// </summary>
        /// <param name="ReCount"></param>
        /// <returns></returns>
        public string DeleteMemberGarbage ( out int ReCount )
        {
            return XGWMS.DBUtility.SqlHelper.ExecuteSql (DAL_System_SQL.DeleteMemberGarbage, out ReCount);
        }

        /// <summary>
        /// 数据库备份
        /// </summary>
        /// <param name="ReCount"></param>
        /// <returns></returns>
        public string BackUp ( string DataBaseName, string Path )
        {
            SqlParameter[] parameters = { new SqlParameter ("@DataBaseName", SqlDbType.VarChar),
                new SqlParameter ("@Path", SqlDbType.VarChar)};
            parameters[0].Value = DataBaseName;
            parameters[1].Value = Path;
            return XGWMS.DBUtility.SqlHelper.ExecuteSqlComm (DAL_System_SQL.BackUp, parameters);
        }

        /// <summary>
        /// 数据库还原
        /// </summary>
        /// <param name="ReCount"></param>
        /// <returns></returns>
        public string ReStore ( string DataBaseName, string Path )
        {
            SqlParameter[] parameters = {new SqlParameter ("@Path", SqlDbType.VarChar)};
            parameters[0].Value = Path;
            return XGWMS.DBUtility.SqlHelper.ExecuteSqlCommWithMaster(DAL_System_SQL.ReStore.Replace("@DataBaseName", DataBaseName), parameters);
        }
    }
}
